﻿<%@ Page Title="" Language="C#" MasterPageFile="~/admin/ADAdminLayout.master" AutoEventWireup="true"
    CodeFile="khuyen_mai.aspx.cs" Inherits="khuyen_mai" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div class="block" id="block-lists">
        <div class="content">
            <h2 class="title">
                Các khuyến mãi đang áp dụng</h2>
            <div class="inner">
                <div class="group">
                    <label>
                        Từ khóa:&nbsp;
                    </label>
                    <asp:TextBox ID="TextBox1" runat="server" class="text_field" size="60"></asp:TextBox>
                    &nbsp;
                    <button class="button slim-button" type="submit">
                        <img src="./images/search.png" alt="Tìm kiếm">
                        Tìm kiếm</button>
                </div>
                <br />
                <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
                    AutoGenerateColumns="False" DataKeyNames="id" DataSourceID="SqlDataSourceKhuyenMai"
                    CssClass="table" >
                    <Columns>
                        <asp:TemplateField HeaderText="STT">
                            <ItemTemplate>
                                <%# Container.DataItemIndex + 1 %>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:HyperLinkField DataNavigateUrlFields="id" 
                            DataNavigateUrlFormatString="./chi_tiet_khuyen_mai.aspx?id={0}" 
                            DataTextField="ten_sp" HeaderText="Tên sản phẩm" />
                        <asp:BoundField DataField="mo_ta_sp" HeaderText="Mô tả sản phẩm" SortExpression="mo_ta_sp" />
                        <asp:BoundField DataField="gia_goc" HeaderText="Giá gốc" SortExpression="gia_goc" />
                        <asp:BoundField DataField="gia_km" HeaderText="Giá khuyến mãi" SortExpression="gia_km" />
                        <asp:BoundField DataField="ngay_bat_dau" HeaderText="Ngày bắt đầu" SortExpression="ngay_bat_dau" />
                        <asp:BoundField DataField="ngay_ket_thuc" HeaderText="Ngày kết thúc" SortExpression="ngay_ket_thuc" />
                        
                        <asp:HyperLinkField DataNavigateUrlFields="id" 
                            DataNavigateUrlFormatString="./cap_nhat_khuyen_mai.aspx?id={0}" 
                            Text="Cập nhật" />
                       
                    </Columns>
                    
                </asp:GridView>
                <asp:SqlDataSource ID="SqlDataSourceKhuyenMai" runat="server" ConnectionString="<%$ ConnectionStrings:babydealConnectionString %>"
                    
                    
                    SelectCommand="SELECT id, id_doanh_nghiep, id_the_loai, ten_sp, mo_ta_sp, gia_goc, gia_km, ngay_bat_dau, ngay_ket_thuc, so_luong_toi_da, so_luong_toi_thieu, noi_dung, dieu_kien_ap_dung, dac_trung, anh_1, anh_2, anh_3, anh_4, anh_5, da_duoc_duyet, id_nhan_vien FROM khuyen_mai WHERE (GETDATE() BETWEEN ngay_bat_dau AND ngay_ket_thuc) AND (ten_sp LIKE N'%' + @ten_sp + N'%')" 
                    DeleteCommand="DELETE FROM [khuyen_mai] WHERE [id] = @id">
                    <DeleteParameters>
                        <asp:Parameter Name="" Type="Int32"/>
                    </DeleteParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="TextBox1" DefaultValue="%%" Name="ten_sp" 
                            PropertyName="Text" />
                    </SelectParameters>
                </asp:SqlDataSource>
                <br />
            </div>
        </div>
    </div>
    <div class="block">
        <div class="content">
            <h2 class="title">
                Các khuyến mãi cũ</h2>
            <div class="inner">
                <div class="group">
                    <label>
                        Từ khóa:&nbsp;
                    </label>
                    <asp:TextBox ID="TextBox2" size="60" CssClass="text_field" runat="server"></asp:TextBox>
                    &nbsp;
                    <button class="button slim-button" type="submit">
                        <img src="./images/search.png" alt="Tìm kiếm">
                        Tìm kiếm</button>
                </div>
                <br />
                <asp:GridView ID="GridView2" runat="server" AllowPaging="True" AllowSorting="True"
                    AutoGenerateColumns="False" DataKeyNames="id" DataSourceID="SqlDataSourceKhuyenMai2"
                    CssClass="table">
                    <Columns>
                        <asp:TemplateField HeaderText="STT">
                            <ItemTemplate>
                                <%# Container.DataItemIndex + 1 %>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:HyperLinkField DataNavigateUrlFields="id" 
                            DataNavigateUrlFormatString="./chi_tiet_khuyen_mai.aspx?id={0}" 
                            DataTextField="ten_sp" HeaderText="Tên sản phẩm" />
                        <asp:BoundField DataField="mo_ta_sp" HeaderText="Mô tả sản phẩm" SortExpression="mo_ta_sp" />
                        <asp:BoundField DataField="gia_goc" HeaderText="Giá gốc" SortExpression="gia_goc" />
                        <asp:BoundField DataField="gia_km" HeaderText="Giá khuyến mãi" SortExpression="gia_km" />
                        <asp:BoundField DataField="ngay_bat_dau" HeaderText="Ngày bắt đầu" SortExpression="ngay_bat_dau" />
                        <asp:BoundField DataField="ngay_ket_thuc" HeaderText="Ngày kết thúc" SortExpression="ngay_ket_thuc" />
                        <asp:BoundField DataField="anh_1" HeaderText="Ảnh đại diện" SortExpression="anh_1" />
                    </Columns>
                </asp:GridView>
                <asp:SqlDataSource ID="SqlDataSourceKhuyenMai2" runat="server" ConnectionString="<%$ ConnectionStrings:babydealConnectionString %>"
                    
                    SelectCommand="SELECT id, id_doanh_nghiep, id_the_loai, ten_sp, mo_ta_sp, gia_goc, gia_km, ngay_bat_dau, ngay_ket_thuc, so_luong_toi_da, so_luong_toi_thieu, noi_dung, dieu_kien_ap_dung, dac_trung, anh_1, anh_2, anh_3, anh_4, anh_5, da_duoc_duyet, id_nhan_vien FROM khuyen_mai WHERE (GETDATE() &gt; ngay_ket_thuc) AND (ten_sp LIKE N'%' + @ten_sp + N'%')">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="TextBox2" Name="ten_sp" PropertyName="Text" DefaultValue="%%" />
                    </SelectParameters>
                </asp:SqlDataSource>
                <br />
            </div>
        </div>
    </div>
</asp:Content>
